<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>打印金字塔</title>
<style>
    .box{background-color:#000;margin:3px;padding:2px;font-size:24px;font-weight:bold;color:#FFF;}
    .out{border:solid 3px #000;float:left;overflow:hidden;}

</style>
</head>
<body>
<div class="out">
<div class="box"></body></html>
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/28 0028
 * Time: 下午 8:22
 */
$line=1;
while($line<=5){
    $empty_pos=$star_pos=1;
    $empty=5-$line;
    $star=2*$line-1;
    while($empty_pos<=$empty){
        echo '&nbsp;';
        ++$empty_pos;
    }while ($star_pos<=$star){
        echo '*';
          ++$star_pos;
    }echo '<br>';
    ++$line;

}

